public class L530 {

    public static void main(String[] args) {
        TreeNode treeNode = new TreeNode(1);
        new Solution().getMinimumDifference(treeNode);
    }

    static class Solution {
        int pre = -1;
        int result = Integer.MAX_VALUE;

        public int getMinimumDifference(TreeNode root) {
            if (root == null) {
                return 0;
            }

            getMinimumDifference(root.left);

            if (-1 != pre) {
                result = Math.min(result, root.val - pre);
            }
            pre = root.val;

            getMinimumDifference(root.right);

            return result;
        }
    }
}
